<?php
// +----------------------------------------------------------------------
// | ThinkPHP
// +----------------------------------------------------------------------
// | Copyright (c) 2008 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id$

import('Think.Util.StringReader');
/**
 +------------------------------------------------------------------------------
 * 文件缓存读取类
 +------------------------------------------------------------------------------
 * @category   ORG
 * @package  ORG
 * @subpackage  Io
 * @author    liu21st <liu21st@gmail.com>
 * @version   $Id$
 +------------------------------------------------------------------------------
 */
class CachedFileReader extends StringReader
{
    function __construct($filename) {
        if (file_exists($filename)) {

          $length=filesize($filename);
          $fd = fopen($filename,'rb');

          if (!$fd) {
        $this->error = 3; // Cannot read file, probably permissions
        return false;
          }
          $this->_str = fread($fd, $length);
          fclose($fd);

        } else {
          $this->error = 2; // File doesn't exist
          return false;
        }
    }
}
?>